


//
//  LJHBaseButton.m
//  HEARME
//
//  Created by liujinhui on 16/1/21.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "LJHBaseButton.h"

@implementation LJHBaseButton
+(instancetype)buttonWithType:(UIButtonType)buttonType
{
    LJHBaseButton *baseBtn = [[LJHBaseButton alloc] init];
    
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Mode"] isEqualToString:@"night"]) {
        baseBtn.backgroundColor = [UIColor colorWithWhite:0.451 alpha:1.000];
        //        [baseBtn setTitleColor:WHITE forState:UIControlStateNormal];
    }
    else
    {
        baseBtn.backgroundColor = [UIColor whiteColor];
        //        [baseBtn setTitleColor:COLOR_SELECTED forState:UIControlStateNormal];
        
    }
    
    [[NSNotificationCenter defaultCenter] addObserver:baseBtn selector:@selector(changeColor:) name:@"changeColor" object:nil];
    
    return baseBtn;
}

-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeColor" object:nil];
    [super dealloc];
}
//-(instancetype) initWithFrame:(CGRect)frame
//{
//    if (self = [super initWithFrame:frame]) {
//
//
//    }
//
//    return self;
//}

-(void)changeColor:(NSNotification *)notifition
{
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Mode"] isEqualToString:@"night"])
    {
        self.backgroundColor = [UIColor colorWithWhite:0.451 alpha:1.000];
        //        [self setTitleColor:WHITE forState:UIControlStateNormal];
        
    }
    else
    {
        self.backgroundColor = [UIColor whiteColor];
        //        [self setTitleColor:COLOR_SELECTED forState:UIControlStateNormal];
        
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
